4
4
.
.
2
2
.
.
1
1
H
H
S
S
t
t
a
a
c
c
k
k
I
I
n
n
f
f
o
o
[
[
R
R
]
]
[
[
R
R
]
]
HStack is Container View which organizes his child Views horizontally next to each other.
You can't have empty HStack.
When adding Views to the Screen you can choose to
insert into existing HStack
insert into new HStack
Enclose existing View inside HStack (You can use this either in the Code or Automatic Preview)
Command + Click on the View + Embed in HStack
Syntax
HStack(alignment: .top, spacing: 200)
Parameters
NAME
DESCRIPTION
HStack(alignment: .top)
Align children at the top
HStack(alignment: .center)
Align children at the center
HStack(alignment: .bottom)
Align children at the bottom
HStack(alignment: .firstTextBaseline)
Align to the bottom of the first text
HStack(alignment: .lastTextBaseline)
Align to the bottom of the last text
HStack(spacing: 30)
Space between children. Instead of Spacer().
E
E
x
x
a
a
m
m
p
p
l
l
e
e
Example
HStack {
Spacer()
Text("First")
Spacer()
Text("Second")
Spacer()
}
Output